#ifndef DRAWWIDGET_H
#define DRAWWIDGET_H
#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#include "GL/glu.h"
#include "GeoMap.h"
#include "GeoLayer.h"
#include "GeoPoint.h"
#include "GeoPolyLine.h"
#include "GeoPolygon.h"
#include "QFileDialog"


class DrawWidget : public QOpenGLWidget,protected QOpenGLFunctions
{
public:
    DrawWidget();
    ~DrawWidget();
    DrawWidget(GeoMap *map);
private:
    void paintGL() override;
    void resizeGL(int w,int h) override;
    void initializeGL() override;
    void drawMap(GeoMap *);
    void drawLayer(GeoLayer *);
    void drawObject(GeoObject *obj);

    void getMapData();

    void clearData();
    void GetOriScale();
    //地图投影
    void MapPrj();
    static void CALLBACK vertexCallback(GLvoid *vertex);
    static void CALLBACK beginCallback(GLenum which);
    static void CALLBACK endCallback  ();
    static void CALLBACK errorCallback(GLenum errorCode);
    static void CALLBACK combineCallback(GLdouble coords[3],GLdouble *vertex_data[4],GLfloat weight[4], GLdouble **dataOut );
    void StartTess(QList<LonLat>);

    GeoMap* map = nullptr;
    double Scale;
    double Xmin,Xmax,Ymin,Ymax;

    double DCWidth;

    double DCHeight;

    double DCLeft;

    double DCBottom;

    double PrjRight;

    double PrjTop;

    double PrjLeft;

    double PrjBottom;

};

#endif // DRAWWIDGET_H
